qx.Class.define("ui.view.LoginWindow", {
			events : {
				"changeLoginData" : "qx.event.type.Data"
			},
			extend : qx.ui.window.Window,
			construct : function() {
				this.base(arguments, "Login");
				var layout = new qx.ui.layout.Basic();
				this.setLayout(layout);
				this.setModal(true);
				this.set({
							showClose : false,
							showMinimize : false,
							showMaximize : false,
							allowMinimize : false,
							allowMaximize : false,
							resizableTop : false,
							resizableBottom : false,
							resizableLeft : false,
							resizableRight : false
						});
				/*
				 * this.setShowClose(false); this.setShowMinimize(false)
				 * this.setShowMaximize(false);
				 */

				var form = new qx.ui.form.Form();

				var username = new qx.ui.form.TextField();
				username.setRequired(true);
				form.add(username, "Username", null, "username");

				var password = new qx.ui.form.PasswordField();
				password.setRequired(true);
				form.add(password, "Password", null, "password");

				var controller = new qx.data.controller.Form(null, form);
				var model = controller.createModel();

				var loginbutton = new qx.ui.form.Button("Login");
				form.addButton(loginbutton);

				var cancelbutton = new qx.ui.form.Button("Cancel");
				form.addButton(cancelbutton);
				cancelbutton.addListener("execute", function() {
							this.close();
						}, this);

				var renderer = new qx.ui.form.renderer.Single(form);
				this.add(renderer);
				loginbutton.addListener("execute", function() {
							if (form.validate()) {
								var loginData = {
									username : controller.getModel()
											.getUsername(),
									password : controller.getModel()
											.getPassword()
								};
								this
										.fireDataEvent("changeLoginData",
												loginData);
								// this.close();
							}
						}, this);

				var service = new ui.service.LoginService();

				this.addListener("changeLoginData", function(ev) {
							var loginData = ev.getData();
							service.login(loginData.username,
									loginData.password, this.yes, function(
											causa) {
										alert(causa);
										form.reset();
									}, this);

						}, this);
				this.addListenerOnce("resize", this.center, this);

			},
			members : {
				yes : function(bienvenida) {
					var mainWindow = new ui.view.MainWindow(bienvenida);
					mainWindow.open();
					mainWindow.maximize();

				}
			}
		});